#!/bin/bash

for file in *
do
    if [[ $file =~ (.+)-mask\.png ]]; then
        echo "Ignoring mask $file"
    elif [[ $file =~ (.+)\.png ]]; then
        echo "Generating mask for $file"
        basefn=${BASH_REMATCH[1]}
        convert "$basefn.png" -channel Alpha -negate -separate "$basefn-mask.png"
    fi
done
